package top.ljjapp.filter;/**
 * @FileName: TimeFilter.java
 * @Package: top.ljjapp.filter
 * @Author: lijiajun
 * <br/>
 * @Created: 2018/11/21 10:57
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;
import java.util.Date;

/**
 * <p></p>
 * <p/>
 * <PRE>
 * <BR> 修改记录
 * <BR>-----------------------------------------------
 * <BR> 修改日期 修改人 修改内容
 * </PRE>
 *
 * @author lijiajun
 */
//@Component
@Slf4j
public class TimeFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("myfilter init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        log.info("myfilter doFilter 开始");
        long start = new Date().getTime();
        filterChain.doFilter(servletRequest, servletResponse);
        log.info( "myfilter 耗时:" + ( new Date().getTime() - start ) );
        log.info("myfilter finish");
    }

    @Override
    public void destroy() {
        log.info("myfilter destroy");
    }
}